package com.sso.oauth2.resource.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * TODO 这里是类注释
 *
 * @author yins
 * @date 2021/07/21 09:24
 **/
@RestController
public class UserController {

    @RequestMapping("/api/userinfo")
    public ResponseEntity<Object> getUserInfo(Principal principal) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return ResponseEntity.ok(authentication);
    }

}
